
#ifndef __QUANTITY_H__
#define __QUANTITY_H__

#include <sstream>
#include <Format.h>


template <class TUnit>
struct Quantity
{
	Quantity(unsigned int ammount, const TUnit &unit):ammountInBaseUnit_m( unit.convertToBaseUnit(ammount) )
	{
	}

	bool operator==( const Quantity &quantity ) const
	{
		return ( ammountInBaseUnit_m == quantity.ammountInBaseUnit_m )? true:false;
	}

	Quantity& operator+=( const Quantity &quantity)
	{
		ammountInBaseUnit_m+= quantity.ammountInBaseUnit_m;

		return *this;
	}

	void print( std::ostream& os, const Format* const format ) const
	{
		format->print( os, ammountInBaseUnit_m);
	}


private:	
	unsigned int ammountInBaseUnit_m;
	
};

template <class TUnit>
Quantity<TUnit> operator+( const Quantity<TUnit> &lhs, const Quantity<TUnit> &rhs )
{
	Quantity<TUnit> ret(lhs);

	ret+=rhs;
	return ret;
}


#endif





